package com.zhicheng.controller;


import com.zhicheng.pojo.result.Result;
import com.zhicheng.service.AliPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@CrossOrigin //跨域
@RestController
@RequestMapping("/pay")
@Api(tags = "网站支付宝支付")
public class AliPayController {

    @Autowired
    private AliPayService aliPayService;

    @GetMapping("/aliPay/{orderId}")
    @ApiOperation("统一收单下单并支付页面接口的调用")
    public Result tradePagePay(@PathVariable String orderId){
        String formStr = aliPayService.tradeCreate(orderId);
        return Result.success(formStr);
    }

    @PostMapping("/aliPay/notify")
    @ApiOperation("支付通知")
    public Result tradeNotify(HttpServletRequest request) throws Exception{
        String result = aliPayService.tradeNotify(request);
        return Result.success(result);
    }



}
